#include "meteorites.h"

Meteorites::Meteorites()
{
    QObject();
    m_x = 0;
    m_y = 0;
    m_pixmap = QPixmap("meteor.png");
    m_angle = 0;
    m_speed = 0;
    m_speed = 0;
}
Meteorites::Meteorites(double x, double y, double angle, double angleInDegrees)
{
    QObject();
    m_x = x;
    m_pixmap = QPixmap("meteor.png");
    m_y = y;
    m_angle = angle;
    m_speed = rand() % 5 +1;
    m_angleInDegrees = angleInDegrees;
}
void Meteorites::draw(QPainter *painter)
{
    // painter->translate(m_x,m_y);
    //painter->setPen(Qt::black);
    // painter->translate(m_x,m_y);
    //painter->rotate(45);
    painter->drawPixmap(- m_pixmap.width() / 2.0 + m_x, -m_pixmap.height() / 2.0 + m_y, m_pixmap);
    //painter->resetTransform();
    //painter->drawEllipse(m_x,m_y,30,30);
    //painter->end();
}
bool Meteorites::update()
{
    m_x += cos(m_angle)*m_speed;
    m_y += sin(m_angle)*m_speed;
    if (m_x>=540 || m_x<=-40 || m_y>=540 || m_y<=-40)
        return false;
    return true;
}
QPointF Meteorites::locate()
{
    return QPointF(m_x,m_y);
}
